/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DataModel;
import java.util.HashMap;

/**
 *
 * @author Carlos
 */
public class OrganizationRelation
{

    // <editor-fold defaultstate="collapsed" desc="Attributes">
    private Organization _organization;
    private HashMap<Integer, User> _projectResponsibles;
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Constructor">
    public OrganizationRelation (Organization organization, User[] projectResponsibles)
    {
        _organization = organization;
        _projectResponsibles = new HashMap<Integer, User>();
        for(int responsibleIndex = 0; responsibleIndex < projectResponsibles.length; responsibleIndex++)
            _projectResponsibles.put(projectResponsibles[responsibleIndex].getId(), projectResponsibles[responsibleIndex]);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Properties">
    public Organization getOrganization()
    {
        return _organization;
    }

    public User[] getProjectResponsibles()
    {
        User[] responsibleArr = new User[_projectResponsibles.size()];
        return _projectResponsibles.values().toArray(responsibleArr);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Methods">
    public void AddResponsible(User newUser)
    {
        if(!_projectResponsibles.containsKey(newUser.getId()))
            _projectResponsibles.put(newUser.getId(), newUser);
    }

    public void RemoveResponsible(User oldResponsible)
    {
        if(_projectResponsibles.containsKey(oldResponsible.getId()))
            _projectResponsibles.remove(oldResponsible.getId());
    }
    // </editor-fold>

}
